/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package basicModelType1.impl;

import generalArchitecture.ComputeBox;

import org.eclipse.emf.ecore.EClass;

import processorUtilizationNB.ProcessorUtilisationNB;
import processorUtilizationNB.impl.ProcessorUtilisationNBImpl;
import technicRMLL73.TechnicRMLL73;
import technicRMLL73.impl.TechnicRMLL73Impl;
import technic_RM_ResponseTimeNB.ResponseTimeRMNB;
import technic_RM_ResponseTimeNB.impl.ResponseTimeRMNBImpl;
import utils.UtilsModelInstance;
import abstractBasicModel.impl.AbstractBasicModelImpl;
import basicModelType1.BasicModelType1;
import basicModelType1.BasicModelType1Package;
import boundRMLL73.BoundRMLL73;
import boundRMLL73.impl.BoundRMLL73Impl;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Basic Model Type1</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * </p>
 *
 * @generated
 */
public class BasicModelType1Impl extends AbstractBasicModelImpl implements BasicModelType1 {
	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected BasicModelType1Impl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return BasicModelType1Package.Literals.BASIC_MODEL_TYPE1;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated NOT
	 */
	public void compute() {
		/* RM Case -> 0*/
		if (this.scheduler == 0) {
			
			/* ================================================= technicRMLL73 ================================================== */
			/* Create instance of technicRMLL73, add to general List, children list and compute */
			TechnicRMLL73 t_rm = (TechnicRMLL73)UtilsModelInstance.lookForComputeBox((ComputeBox)this, TechnicRMLL73Impl.class);
			
			/**/
			if (t_rm == null) {
				
				t_rm = UtilsModelInstance.createTechnicRMLL73(null, null);
				UtilsModelInstance.linkComputeBox((ComputeBox)this, t_rm, false);
			}
			/**/
			else {
				UtilsModelInstance.linkComputeBox((ComputeBox)this, t_rm, true);
			}
			t_rm.compute();
			
			/* ================================================= BoundRMLL73 ================================================== */
			/* Create instance of BoundRMLL73, add to general List, children list and compute */
			BoundRMLL73 b_rm = (BoundRMLL73)UtilsModelInstance.lookForComputeBox((ComputeBox)this, BoundRMLL73Impl.class);
			
			/**/
			if (b_rm == null) {
				
				b_rm = UtilsModelInstance.createBound_RM_LL73(this.getPeriod().size());
				UtilsModelInstance.linkComputeBox((ComputeBox)this, b_rm, false);
			}
			/**/
			else {
				UtilsModelInstance.linkComputeBox((ComputeBox)this, b_rm, true);
			}
			b_rm.compute();
			
			/* ================================================= ProcessorUtilisationNB ================================================== */
			/* Create instance of ProcessorUtilisationNB, add to general List, children list and compute */
			ProcessorUtilisationNB pu = (ProcessorUtilisationNB)UtilsModelInstance.lookForComputeBox((ComputeBox)this, ProcessorUtilisationNBImpl.class);
			
			/**/
			if (pu == null) {
				
				pu = UtilsModelInstance.createPUNB(period, wcet);
				UtilsModelInstance.linkComputeBox((ComputeBox)this, pu, false);
			}
			/**/
			else {
				UtilsModelInstance.linkComputeBox((ComputeBox)this, pu, true);
			}
			pu.compute();
				
			/* ================================================= ResponseTimeRMNB ================================================== */
			/* Create instance of ResponseTimeRMNB, add to general List, children list and compute */
			ResponseTimeRMNB rt_rmnb = (ResponseTimeRMNB)UtilsModelInstance.lookForComputeBox((ComputeBox)this, ResponseTimeRMNBImpl.class);
			
			/**/
			if (rt_rmnb == null) {
				
				rt_rmnb = UtilsModelInstance.createResponseTime_RM_NB(this.id, this.wcet, this.period, this.deadline);
				UtilsModelInstance.linkComputeBox((ComputeBox)this, rt_rmnb, false);
			}
			/**/
			else {
				UtilsModelInstance.linkComputeBox((ComputeBox)this, rt_rmnb, true);
			}
			rt_rmnb.compute();
			
		}
		
		/* EDF Case*/
		else {
			
		}
	}

} //BasicModelType1Impl

